﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;


namespace WindowsFormsApplication1
{
    public class DBhleper
    {
        static string con = "Data Source=.;Initial Catalog=XM_ci;Integrated Security=True";
        public static int writ(string sql)
        {
            //SqlConnection com = new SqlConnection(con);
            //SqlCommand exe = new SqlCommand(sql,com);
            //com.Open();
            //int fh=exe.ExecuteNonQuery();
            //com.Close();
            //return fh;

            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "Data Source=.;Initial Catalog=DB_5_28;Integrated Security=True";

            conn.Open();

            SqlCommand com = new SqlCommand();
            com.Connection = conn;
            com.CommandText = sql;

            int fh = com.ExecuteNonQuery();

            conn.Close();
            return fh;
        }

        public static DataTable read(string sql)
        {
            SqlConnection com = new SqlConnection(con);
            SqlCommand dataa = new SqlCommand(sql, com);
            com.Open();
            DataTable lsb = new DataTable();
            SqlDataAdapter data = new SqlDataAdapter(dataa);
            data.Fill(lsb);
            com.Close();
            return lsb;
        }
    }
}
